﻿using System;
class ConvertHexToDec
{
    static int HexadecimalToDecimal(string HeNumber)
    {
        int digit = 0;
        int result = 0;
        string temp = string.Empty;
        for (int i = 0; i < HeNumber.Length; i++)
        {
            temp = string.Empty;
            try
            {
                temp = temp+HeNumber[i];
                digit = int.Parse(temp);
            }
            catch (Exception)
            {
                switch (HeNumber[i])
                {
                    case 'A':
                        {
                            digit = 10;
                            break;
                        }
                    case 'B':
                        {
                            digit = 11;
                            break;
                        }
                    case 'C':
                        {
                            digit = 12;
                            break;
                        }
                    case 'D':
                        {
                            digit = 13;
                            break;
                        }
                    case 'E':
                        {
                            digit = 14;
                            break;
                        }
                    case 'F':
                        {
                            digit = 15;
                            break;
                        }
                    default:
                        {
                            break;
                        }
                }
            }
            result = result + digit * ((int)Math.Pow(16, (HeNumber.Length - 1 - i)));
        }
        return result;
    }
    static void Main()
    {
        Console.Write("please input Hex number: ");
        string hexNumber = Console.ReadLine();
        int res = HexadecimalToDecimal(hexNumber);
        Console.Write("decimal representation of {0}, is: ", hexNumber);
        Console.WriteLine(res);
        Console.ReadLine();
    }
}

